<!doctype html>
<html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false"%>
<head>
    <title>${registrationNO}-视频监控</title>
    <%@ include file="videoHead.jsp"%>
    <style>
    .select2.select2-container.select2-container--default{
    	margin-top:1px;
    	top:-25px;
    	left:132px;
    }
     #driverInfo{
    	padding:50px 20px 0 20px;
    	background:rgba(255,255,255,0.9);
    }
    </style>
</head>
<body class="hkMin" onLoad="InitOcx()" onUnload="StopPlay(),DisConnect()">
<div style="height:100%;width:100%">
	
	<div style="width:60%;height:100%;float: left;border:double;background: url(${appCtx}resources/images/video/bg.jpg) #ededed no-repeat 50% 0;">
		<object	classid="clsid:EE4EA829-B8DA-4229-AC72-585AF45AD778" codebase="" standby="Waiting..." 
			id="ppvs1" width="49%" height="50%" name="ocx1" title="视频">
			<a class="videoBtn" href="${ocxPath}OcxHK.exe" id="downloadVideoControl">下载视频控件</a>
		</object>
		<object	classid="clsid:EE4EA829-B8DA-4229-AC72-585AF45AD778" codebase="" standby="Waiting..." 
			id="ppvs2" width="49%" height="50%" name="ocx2" title="视频">
		</object>
		<object	classid="clsid:EE4EA829-B8DA-4229-AC72-585AF45AD778" codebase="" standby="Waiting..." 
			id="ppvs3" width="49%" height="50%" name="ocx3" title="视频">
		</object>
		<object	classid="clsid:EE4EA829-B8DA-4229-AC72-585AF45AD778" codebase="" standby="Waiting..." 
			id="ppvs4" width="49%" height="50%" name="ocx4" title="视频">
		</object>
	</div>
	<div  style="width:40%;height:100%;float: left;margin-left:0px;padding-left: 5px;border-right: 1px solid #eee;position:relative">
	
	<div id="tooldiv" style="position: absolute;z-index: 300;right: 10px;top:5px;">

		<select class="dn" style="width:130px;margin: 0px;" id="timeOutSel">
		<option value ="60" selected="selected">5分钟后关闭</option>
  		<option value ="600">10分钟后关闭</option>
  		<option value="1200">20分钟后关闭</option>
  		<option value="1800">30分钟后关闭</option>
  		</select>
  		<div class="timeEnd">
  			<span id="t_m" class="dn paddingLeft-5">00分</span> 
			<span id="t_s" class="paddingLeft-5">00秒</span>
  		</div>
		<a class="videoBtn fl" href="javascript:;" id="closeVideoDiv" >关闭视频</a>
		<a class="dirverBtn fl" href="javascript:;" id="queryDriverDiv" style='margin-top:1px;padding:0 3px' >司机信息</a>
		<div class='fl'>
			<select class="videoSelect fl" id="selectVehicleSel" onchange="changeVechile()"  style="width:100px;margin: 0px;">
		</select>
		</div>
	</div>
	
		<div id="gdMap"  style="height:60%;width:100%"></div>
		<div id="speedDiv" style="height:40%;width:100%" >
			<div id="speedCharts" style="width:100%;height: 100%;"></div>
		</div>
		<div id="driverInfo" class="text" style="display: none; position:absolute;z-index:200;top: 0px;left:0; transform-origin: 106px 101.5px 0px;background:white;width:100%;height:100%">
		
	</div>
	
</div>	
	
</div>
<!-- 用于控制弹出窗口- -->
<a id="txtOpenWindow" target="_self" style="display: none"></a>

<script>
queryDriverInfo();
var oneDay = 10 * 1000;
var date = [];

var data = [];
var now = new Date();
var nowstr="";
var vehicleID ="${vehicleID}";	
var iConnHandle = -1;		//连接设备返回句柄
var iConnHandle2 = -1;
var iConnHandle3 = -1;
var iConnHandle4 = -1;
var iPlayHandle = -1;		//播放视频返回句柄
var iPlayHandle2 = -1;
var iPlayHandle3 = -1;
var iPlayHandle4 = -1;
var iChannel = 1;			//设备视频通道
var iStreamType = 1;		//取设备流类型	0：主码流	1：子码流
var iRegisterNo = '${Route}';		//设备注册线路编号，以iVMS-7200平台添加设备时选择路线为标准，route1对应线路编号为1，route2对应线路编号为2,依次类推
var commno ="${commno}";
var RegIp='${RegIp}';
var RegPort='${RegPort}';
var StreamIp='${StreamIp}';
var StreamPort='${StreamPort}';
var AlarmIp='${AlarmIp}';
var AlarmPort='${AlarmPort}';
var DeviceId='${DeviceId}'; 
var regNO ="${registrationNO}";
var vehicleColor="${vehicle_color}";
var TEXT="${TEXT}";
var internal_number ="${internal_number}";
var positionNum='${position}';
var obj = null;
var intsetInterval=0;
var isinitselect = true;
var  appCtx="${appCtx}";
var defaultTime =60;
var intsetIntervalSub=0;
var curgpstime="";	
var curaddress="";
var trackArray=new Array();
var infoWindow;
var isopenWin=false;
var isMineOp=false;
var marker;
var map ;
var myChart;

var option = {
	    xAxis: {
	        type: 'category',
	        boundaryGap: false,
	        data: date
	    },
	    grid:{
	    	x:30,
	    	y:30,
	    	x2:10,
	    	y2:10
	    	
	    },
	    tooltip: {
	        trigger: 'axis',
	        formatter: function (params) {
	            params = params[0];
	            return "时间:"+params.name+"<br/>"+"速度:"+params.value;
	        },
	        axisPointer: {
	            animation: false
	        }
	    },
	    yAxis: {
	        boundaryGap: [0, '50%'],
	        name : ' 速度(km/h)',
		    type : 'value',
		    max : 150,
	    },
	    series: [
	        {
	            name:'速度',
	            type:'line',
	            smooth:true,
	            symbol: 'none',
	            stack: 'a',
	            data: data
	        }
	    ]
	};
$(function(){ 
	try{
		map = new AMap.Map('gdMap', {
		    resizeEnable: true,
		    zoom:11,
		    center: [106.713453, 26.571933]
		});

		
		myChart = echarts.init(document.getElementById('speedCharts'));
		myChart.setOption(option);

		updatemyChart();
			

		initVehicleList();
		subScribeVehicle();
		 defaultTime =$("#timeOutSel").val();
		 setTimeout("Play()", 3000 ); 
		 intsetInterval=window.setInterval("timeOut();", 1000);
		 $("#closeVideoDiv").unbind("click");
		 $("#closeVideoDiv").bind("click",buttonCloseVideo);
		 $("#closeVideoDiv").html("关闭视频")
		 intsetIntervalSub=window.setInterval("subScribeVehicle();", 10000);
	}catch(e){
		  
	}
});

function updatemyChart() {
    myChart.setOption({
        xAxis: {
            data: date
        },
        series: [{
            name:'速度',
            data: data
        }]
    });
}

function initVehicleList(){
	$.ajax({
		type : 'post',
		async : false,
		url : appCtx + "/video/queryVideoVehicleList.html",
		cache : false,
		dataType : "JSON",
		success : function(data) {
			if(data){

				$('#selectVehicleSel').select2({
				  data: data
				})
				
				$('#selectVehicleSel').val(vehicleID).trigger("change");
			}
		}
	});

}

function queryDriverInfo(){
	$("#queryDriverDiv").click(function(){
		$.ajax({
			type : 'post',
			async : true,
			data :{"vehicle_no_color": TEXT + "_" + vehicleColor},
			url : appCtx + "/video/queryDriverInfomation.html",
			cache : false,
			dataType : "JSON",
			success : function(data) {
				if(data){
					//时间处理
					var driveTotalTime=data.totalDriverTime;
					var days    = driveTotalTime / 1000 / 60 / 60 / 24;
					var daysRound   = Math.floor(days);
					var hours    = driveTotalTime/ 1000 / 60 / 60 - (24 * daysRound);
					var hoursRound   = Math.floor(hours);
					var minutes   = driveTotalTime / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
					var minutesRound  = Math.floor(minutes);
					var isTired =data.tired==0?"否":"是";
					var img=data.imgUrl;
					var driverName= (typeof data.driverName == 'undefined')?"":data.driverName;
					var jsonStr ="<p style='text-align:left'><span style='font-family:'微软雅黑', '微软雅黑''>当前司机：" + driverName + "</span></p>"+
		              "<p><span style='font-family:'微软雅黑', '微软雅黑''>总驾驶时长：" + hoursRound +"小时"+ minutesRound +"分钟" + "</span></p>"+
		              "<p><span style='font-family:'微软雅黑', '微软雅黑''>是否疲劳驾驶：" + isTired + "</span></p>"+
		              "<p><span style='font-family:'微软雅黑', '微软雅黑''>驾驶期间最高时速：" + data.max_speed + "km/h</span></p>"+
		              "<p><span style='font-family:'微软雅黑', '微软雅黑''>驾驶期间超速次数：" + data.overspeed_count + "次</span></p>"+
		              "<img src= " +  img  + " style= \"width:100px; height:100px\">";
					$('#driverMiniInfo').html(jsonStr);  
				}
			}
		});
	})
}


var isClick = false;
$('#queryDriverDiv').click(function(){
    if (!isClick) {
        $('#driverInfo').fadeIn();
        isClick = true;
    }else{
        $('#driverInfo').fadeOut();
        isClick = false;
    }
});

function getVehicleStatusPicUrl(head,status){
    var carStatus = ['car','car','carYellow','red','gray'];
    var picUrl = appCtx + "resources/images/mapTool/";
    try{
        picUrl += (carStatus[status])+getHead(head)+".png";
        return picUrl;
    }catch(ex){
        console.log(ex);
        return picUrl  = appCtx + "resources/images/mapTool/car1.png";  //出错的话 默认车辆图标
    }
}

function getHead(head){
    var head=head;
    if ((head >= 0 && head < 22) || (head >= 336)){
        return 3;
    }else if (head >=22 && head <66){
        return 7;
    }else if (head >=66 && head <112){
        return 1;
    }else if (head >=112 && head <=156){
        return 8;
    }else if (head >=156 && head <202){
        return 4;
    }else if (head >=202 && head <= 246){
        return 5;
    }else if (head >=246 && head <292){
        return 2;
    }else if (head >=292 && head <336){
        return 6;
    }
}

/**
* 删除所有覆盖物
* 
*/
function clearAllMarker(){
	map.clearMap(); 
}

function closeInfoWin(){
	if(isMineOp){
		isopenWin=false;
	}
	
}

function subScribeVehicle(){
	var getTimestamp=new Date().getTime();
	$.ajax({
        url : appCtx+'gis/monitor/subScribe.html?v='+getTimestamp,
        data :{"vehicle_no_color":TEXT+"_"+vehicleColor},
        success : function(datar){

       	 if(datar&&datar.length>0){
       		 
       	 
       	 var result = JSON.parse(datar);
        	 if(result.data.length>0){
        		if(curgpstime!=result.data[0].gpsTimeS){
          		 var arrgps=[];
          		 arrgps.push(result.data[0].longitude);
          		 arrgps.push(result.data[0].latitude);
          		 isMineOp=false;
          		 clearAllMarker();
          		 isMineOp=true;
          		 var picUrl = getVehicleStatusPicUrl(result.data[0].head,result.data[0].carStatus);
          		 infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(0, -10)}); 
          		infoWindow.on('close', closeInfoWin);
          			marker = new AMap.Marker({
          		        map:map,
          		        position: [result.data[0].longitude, result.data[0].latitude],
          		        icon: picUrl,
          		        offset: new AMap.Pixel(-15, -10)
          		    });
          			marker.content = '车牌号：'+TEXT +'</br>定位时间：'+result.data[0].gpsTimeS+'</br>速度：'+result.data[0].gpsSpeedF+' 公里/小时</br>里程：'+result.data[0].gpsMileage+' 公里';
          			marker.on('click', function(e){
          				 isopenWin=true;
          				 infoWindow.setContent(e.target.content);
          			     infoWindow.open(map, e.target.getPosition());
          			     
          			   	 
          			});
          			if(isopenWin){
          				infoWindow.setContent(marker.content);
          				infoWindow.open(map,marker.getPosition());
          			}
          			
          		 trackArray.push(arrgps);
          		 

          	 
          		 if(trackArray.length>1){
          			 	var polyline = new AMap.Polyline({
          			        path: trackArray,          //设置线覆盖物路径
          			        strokeColor: "#3366FF", //线颜色
          			        strokeOpacity: 1,       //线透明度
          			        strokeWeight: 5,        //线宽
          			        strokeStyle: "solid",   //线样式
          			        strokeDasharray: [10, 5] //补充线样式
          			    });
          			    polyline.setMap(map);
          		 }
          		 map.setCenter(new AMap.LngLat(result.data[0].longitude, result.data[0].latitude))
          		 
          		 curgpstime=result.data[0].gpsTimeS;
          		 date.push(result.data[0].gpsTimeS.substring(11,19));
              	 data.push(result.data[0].gpsSpeedF);
              	 updatemyChart();
          	 }
        	 }

        }
        }
    });
	

}



//在指定位置打开信息窗体
function openInfo() {
    infoWindow.open(map, map.getCenter());
}

function timeOut(){
	if(defaultTime>0){
		defaultTime--;
		var m=Math.floor(defaultTime/60%60); 
		var s=Math.floor(defaultTime%60);
		if(m<10){
			document.getElementById("t_m").innerHTML = "0"+m + "分"; 
		}else{
			document.getElementById("t_m").innerHTML = m + "分"; 
		}
		if(s<10){
			document.getElementById("t_s").innerHTML = "0"+s + "秒";
		}else{
			document.getElementById("t_s").innerHTML = s + "秒";
		}
	}else{
		document.getElementById("t_m").innerHTML = "00" + "分";
		document.getElementById("t_s").innerHTML = "00" + "秒";
		window.clearInterval(intsetInterval);
		StopPlay();  
		$("#closeVideoDiv").unbind("click");
		$("#closeVideoDiv").bind("click",buttonOpenVideo);
		$("#closeVideoDiv").html("打开视频")
	}
}

function buttonOpenVideo(){
	 defaultTime =$("#timeOutSel").val();
	 Play();
	 intsetInterval=window.setInterval("timeOut();", 1000);
	 $("#closeVideoDiv").unbind("click");
	 $("#closeVideoDiv").bind("click",buttonCloseVideo);
	 $("#closeVideoDiv").html("关闭视频")
}
function buttonCloseVideo(){
	defaultTime=0;
	document.getElementById("t_m").innerHTML = "00" + "分";
	document.getElementById("t_s").innerHTML = "00" + "秒";
	window.clearInterval(intsetInterval);
	StopPlay(); 
	$("#closeVideoDiv").unbind("click");
	$("#closeVideoDiv").bind("click",buttonOpenVideo);
	$("#closeVideoDiv").html("打开视频")
}

function setTimeOut(){
	 Play();
	 $("#resetTimeout").hide();
	 $("#time_label").show();
	defaultTime = videoOverTime;
}

    var map = new AMap.Map('gdMap', {
        resizeEnable: true,
        zoom:11,
        center: [106.397428, 26.90923]
    });

//初始化控件
function InitOcx()
{

		try
		{
			//根据控件的PorgID来判断是否注册，未注册则抛出异常
			obj = new ActiveXObject("ppvsGUARD.ppvsguardCtrl.1");
			
			//设置窗口模式
			var PlayOCX = document.getElementById("ppvs1");
			var PlayOCX2 = document.getElementById("ppvs2");
			var PlayOCX3 = document.getElementById("ppvs3");
			var PlayOCX4 = document.getElementById("ppvs4");
			
			if ( typeof PlayOCX == "undefined" || PlayOCX == null )
			{
				//document.getElementById("ShowMessage").value = "控件已注册但页面对象不存在！\r\n";
				console.log("控件已注册但页面对象不存在！");
				return;
			}
			PlayOCX.SetActiveXShowMode(0,0);//实时预览模式，需要修改模式或者窗口UI可参考SetActiveXShowMode接口说明
			PlayOCX2.SetActiveXShowMode(0,0);
			PlayOCX3.SetActiveXShowMode(0,0);
			PlayOCX4.SetActiveXShowMode(0,0);
			//document.getElementById("ShowMessage").value = "控件已注册并初始化完成！\r\n";
			console.log("控件已注册并初始化完成！");
			ConnDevice();
		}
		catch ( e )
		{
			//document.getElementById("ShowMessage").value = "控件未注册或未安装！\r\n";
			console.log("控件未注册或未安装！");
		}

}

//连接设备
function ConnDevice()
{
	try{
		//设备注册信息
		var szAccount = DeviceId;
		//注册服务IP、端口
		var szRegIP = RegIp;
		var iRegPort = RegPort;

		//var PreText = document.getElementById("ShowMessage").value;
		var PlayOCX = document.getElementById("ppvs1");
		var PlayOCX2 = document.getElementById("ppvs2");
		var PlayOCX3 = document.getElementById("ppvs3");
		var PlayOCX4 = document.getElementById("ppvs4");
		if ( typeof obj == "undefined" || obj == null )
		{
			//document.getElementById("ShowMessage").value = PreText + "控件未注册！\r\n";
			console.log("控件未注册！");
			return;
		}
		if ( typeof PlayOCX == "undefined" || PlayOCX == null )
		{
			//document.getElementById("ShowMessage").value = PreText + "控件已注册但页面对象不存在！\r\n";
			console.log("控件已注册但页面对象不存在！");
			return;
		}
		
		if ( typeof szAccount == "undefined" || szAccount == null || szAccount == "")
		{
			//document.getElementById("ShowMessage").value = PreText + "设备ID不能为空！\r\n";
			console.log("设备ID不能为空！");
			return;
		}
		var ShowMsg = "停止预览失败！\r\n";
		iConnHandle = PlayOCX.ConnectDeviceByACS(szAccount, szRegIP, iRegPort, "admin", "12345");
		iConnHandle2=PlayOCX2.ConnectDeviceByACS(szAccount, szRegIP, iRegPort, "admin", "12345");
		iConnHandle3=PlayOCX3.ConnectDeviceByACS(szAccount, szRegIP, iRegPort, "admin", "12345");
		iConnHandle4=PlayOCX4.ConnectDeviceByACS(szAccount, szRegIP, iRegPort, "admin", "12345");

		if (iConnHandle < 0)
		{
			ShowMsg = "连接设备失败！\r\n";
		}
		else
		{
			ShowMsg = "连接设备成功！\r\n";
		}
		//document.getElementById("ShowMessage").value = PreText + ShowMsg;
		console.log(ShowMsg);
	}catch(e){
			
	}
	
}

//实时预览
function Play()
{
	try{
		//var PreText = document.getElementById("ShowMessage").value;
		var ShowMsg = "正在预览中...\r\n";
		if ( typeof obj == "undefined" || obj == null )
		{
			//document.getElementById("ShowMessage").value = PreText + "控件未注册或未安装！\r\n";
			console.log("控件未注册或未安装！");
			return;
		}
		
		var PlayOCX = document.getElementById("ppvs1");
		var PlayOCX2 = document.getElementById("ppvs2");
		var PlayOCX3 = document.getElementById("ppvs3");
		var PlayOCX4 = document.getElementById("ppvs4");
		if ( typeof PlayOCX == "undefined" || PlayOCX == null )
		{
			document.getElementById("ShowMessage").value = PreText + "控件已注册但页面对象不存在！\r\n";
			console.log("控件已注册但页面对象不存在！");
			return;
		}

		if (iConnHandle < 0)
		{
			ShowMsg = "请先连接设备，并确保连接成功！\r\n";
			//document.getElementById("ShowMessage").value = PreText + ShowMsg;
			console.log(ShowMsg);
			return;
		}
		
		if(isNaN(iRegisterNo)){
			iRegisterNo=2;
		}else{
			iRegisterNo=parseInt(iRegisterNo); 
		}
		
		var szAccount = DeviceId;
		//iChannel = document.getElementById("ChannelNo").value;
		//流媒体服务器信息
		var szStreamServerIP = StreamIp;
		var iStreamServerPort = StreamPort;
		
		//有视频播放，则先停止
		if( iPlayHandle>0 )
		{
			StopPlay();
		}
		//设置设备注册线路编号，以iVMS-7200添加设备选择注册线路匹配
		PlayOCX.SetDeviceNetLine(iRegisterNo);
		PlayOCX2.SetDeviceNetLine(iRegisterNo);
		PlayOCX3.SetDeviceNetLine(iRegisterNo);
		PlayOCX4.SetDeviceNetLine(iRegisterNo);
		//取流类型
		iStreamType = 1;
		
		//客户端到流媒体采用TCP，流媒体到设备采用TCP取流
		iPlayHandle = PlayOCX.StreamPlayStartByTCP(szStreamServerIP, iStreamServerPort, szAccount, 1, iStreamType, 1);
		iPlayHandle2=PlayOCX2.StreamPlayStartByTCP(szStreamServerIP, iStreamServerPort, szAccount, 2, iStreamType, 1);
		iPlayHandle3=PlayOCX3.StreamPlayStartByTCP(szStreamServerIP, iStreamServerPort, szAccount, 3, iStreamType, 1);
		iPlayHandle4=PlayOCX4.StreamPlayStartByTCP(szStreamServerIP, iStreamServerPort, szAccount, 4, iStreamType, 1);
				
		if (-1 == iPlayHandle)
		{
			ShowMsg = "预览失败！\r\n";
			//document.getElementById("ShowMessage").value = PreText + ShowMsg;
			console.log("预览失败！");
			return;		
		}	
			
		//设置窗口的设备信息显示
		//var szMode = "TCP";
		//PlayOCX.SetDeviceInfoForShow( ">>> 转发取流("+szMode+") <<<" );
		//PlayOCX2.SetDeviceInfoForShow( ">>> 转发取流("+szMode+") <<<" );
		//PlayOCX3.SetDeviceInfoForShow( ">>> 转发取流("+szMode+") <<<" );
		//PlayOCX4.SetDeviceInfoForShow( ">>> 转发取流("+szMode+") <<<" );
	}catch(e){
			
	}
	
}

//停止预览
function StopPlay()
{	
	try{
		//var PreText = document.getElementById("ShowMessage").value;
		var PlayOCX = document.getElementById("ppvs1");
		var PlayOCX2 = document.getElementById("ppvs2");
		var PlayOCX3 = document.getElementById("ppvs3");
		var PlayOCX4 = document.getElementById("ppvs4");
		if ( typeof obj == "undefined" || obj == null )
		{
			//document.getElementById("ShowMessage").value = PreText + "控件未注册或未安装！\r\n";
			console.log("控件未注册或未安装！");
			return;
		}

		if ( typeof PlayOCX == "undefined" || PlayOCX == null )
		{
			//document.getElementById("ShowMessage").value = PreText + "控件已注册但页面对象不存在！\r\n";
			console.log("控件已注册但页面对象不存在！");
			return;
		}

		var ShowMsg = "停止预览失败！\r\n";
		if( iPlayHandle >= 0 )
		{
			if(PlayOCX.StreamPlayStopByTCP())
			{
				iPlayHandle = -1;
				ShowMsg = "预览已停止！\r\n"
			}
		}
		if(iPlayHandle2 >= 0){
			if(PlayOCX2.StreamPlayStopByTCP())
			{
				iPlayHandle2 = -1;
				ShowMsg = "预览已停止！\r\n"
			}
		}
		if(iPlayHandle3 >= 0){
			if(PlayOCX3.StreamPlayStopByTCP())
			{
				iPlayHandle3 = -1;
				ShowMsg = "预览已停止！\r\n"
			}
		}
		if(iPlayHandle4 >= 0){
			if(PlayOCX4.StreamPlayStopByTCP())
			{
				iPlayHandle4 = -1;
				ShowMsg = "预览已停止！\r\n"
			}
		}
		else
		{
			ShowMsg = "预览未开启！\r\n";
		}
		//document.getElementById("ShowMessage").value = PreText + ShowMsg;
		console.log(ShowMsg);
	}catch(e){
			
	}
	
}

//断开与设备连接
function DisConnect()
{
	try{
		//var PreText = document.getElementById("ShowMessage").value;
		var PlayOCX = document.getElementById("ppvs1");
		if ( typeof obj == "undefined" || obj == null )
		{
			//document.getElementById("ShowMessage").value = PreText + "控件未注册或未安装！\r\n";
			console.log("控件未注册或未安装！");
			return;
		}

		if ( typeof PlayOCX == "undefined" || PlayOCX == null )
		{
			//document.getElementById("ShowMessage").value = PreText + "控件已注册但页面对象不存在！\r\n";
			console.log("控件已注册但页面对象不存在！");
			return;
		}

		var ShowMsg = "与设备断开连接失败！\r\n";
		if( iConnHandle>0 )
		{
			if( PlayOCX.DisConnectDevice() )
			{
				iConnHandle = -1;
				ShowMsg = "与设备已断开连接！\r\n";
			}
		}
		else
		{
			ShowMsg = "设备未连接！\r\n";
		}
		//document.getElementById("ShowMessage").value = PreText + ShowMsg;
		console.log(ShowMsg);
	}catch(e){
			
	}
	
}

function addData(shift) {
    var hourstr=now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
    var minutestr=now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();
    var secondstr=now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();
    nowstr = [hourstr, minutestr, secondstr].join(':');
    date.push(nowstr);
    data.push(parseFloat(Math.random() * 30+50).toFixed(1));

    if (shift) {
        date.shift();
        data.shift();
    }

    now = new Date(+new Date(now) + oneDay);
}



	
//打开新窗体
function openWindow(url){
	var openLink = $("#txtOpenWindow");
	openLink.attr('href', url);
	openLink[0].click();
}
function changeVechile(){

	if(isinitselect){
		isinitselect=false;
	}else{
		if($("#closeVideoDiv").html()=="关闭视频"){
			alert("需要关闭当前正在播放的视频才能进行切换！");
			isinitselect=true;
			$('#selectVehicleSel').val(vehicleID).trigger("change");
		}else{
			var vid=$("#selectVehicleSel").val();
			if(parent.window.vehicleID1==vid&&vid!=0){
				alert("左上监控区域正在监控该车辆！");
				isinitselect=true;
				$('#selectVehicleSel').val(vehicleID).trigger("change");
				return;
			}
			if(parent.window.vehicleID2==vid&&vid!=0){
				alert("右上监控区域正在监控该车辆！");
				isinitselect=true;
				$('#selectVehicleSel').val(vehicleID).trigger("change");
				return;
			}
			if(parent.window.vehicleID3==vid&&vid!=0){
				alert("左下监控区域正在监控该车辆！");
				isinitselect=true;
				$('#selectVehicleSel').val(vehicleID).trigger("change");
				return;
			}
			if(parent.window.vehicleID4==vid&&vid!=0){
				alert("右下监控区域正在监控该车辆！");
				isinitselect=true;
				$('#selectVehicleSel').val(vehicleID).trigger("change");
				return;
			}
			
			
			try{
				parent.window.changeIframe(vid,positionNum,commno);
			}catch(e){
				
			}
			
		/* 	var vid=$("#selectVehicleSel").val();
			openWindow(appCtx + "/video/videoMonitor.html?vehicleID="+vid); */
		}
		
	}
}

</script>
</body>
</html>
